package com.my.util;

import java.sql.*;

import java.sql.Connection;
import java.sql.SQLException;

public class DBCon {
    public static final String url ="jdbc:mysql//localhost:3306/db_hbook?characterEncoding=utf8";
    public static final String name="con.mysql.cj.jdbc.Driver";
    public static final String user="roat";
    public static final String passWord="123";

    private Connection con;

    public Connection getConnection() {
        try{
            Class.forName("con.mysql.cj.jdbc.Driver");
            con =DriverManager.getConnection("jdbc:mysql//localhost:3306/db_hbook?characterEncoding=utf8","roat","123456");
        }catch (ClassNotFoundException e){
            e.printStackTrace();
        }catch (SQLException e){
            e.printStackTrace();
        }
        return con;
    }

    public static void main(String[] args) {
        DBCon db =new DBCon();
        System.out.println("con="+ db.getConnection());
    }
}
